<!DOCTYPE html>
<html lang="en">
<head>
    <head>
        <meta charset="utf-8">
        <title>更新电影作品</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all">
        <link rel="stylesheet" href="../../lib/layui/css/layui.mobile.css" media="all">
        <link rel="stylesheet" href="../../css/public.css" media="all">
        <style>
            body {
                background-color: #ffffff;
            }
        </style>
    </head>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px">
            <legend>更新电影作品</legend>
        </fieldset>

        <form class="layui-form" action="">
            <input type="hidden" name="id" value=""/>
            <div class="layui-form-item layui-col-md10">
                <label class="layui-form-label">封面图</label>
                <div class="layui-input-block">
                    <input type="text" name="cover_uri" placeholder="输入作品封面图片uri" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-col-md10">
                <label class="layui-form-label">电影名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required|name" autocomplete="off" placeholder="请输入电影名称"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline layui-col-md4">
                    <label class="layui-form-label">是否要查找</label>
                    <div class="layui-input-block">
                        <input type="radio" name="has_search" value="1" title="是" checked>
                        <input type="radio" name="has_search" value="0" title="否">
                    </div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">发布时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="pub_time" id="pub_time" lay-verify="pub_time" class="layui-input"
                               autocomplete="off" placeholder="yyyy-MM-dd">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">类别</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="category[Male1]"  title="大陆">
                    <input type="checkbox" name="category[Male2]"  title="教育">
                    <input type="checkbox" name="category[Male3]"  title="恐怖">
                    <input type="checkbox" name="category[Male4]"  title="青春偶像">
                    <input type="checkbox" name="category[Male5]"  title="大陆">
                    <input type="checkbox" name="category[Male6]"  title="教育">
                    <input type="checkbox" name="category[Male7]"  title="恐怖">
                    <input type="checkbox" name="category[Male8]"  title="青春偶像">
                    <input type="checkbox" name="category[Male9]"  title="灾难">
                    <input type="checkbox" name="category[Male0]"  title="星际救援">
                    <input type="checkbox" name="category[Female]" title="未来">
                </div>
            </div>
            <div class="layui-form-item layui-col-md5">
                <label class="layui-form-label">类型</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="Film" title="电影">
                    <input type="radio" name="type" value="Play" title="综艺">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">电影简介</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" id="lay_intro_editor" lay-verfiy="intro" name="intro"></textarea>
                </div>
            </div>

            <!--表单提交控制Item-->
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" type="button" lay-submit="" lay-filter="save">立即提交</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置表单</button>
                </div>
            </div>

        </form>
    </div>
</div>

<script src="../../lib/layui/layui.all.js" charset="utf-8"></script>
<script src="../../js/layui-config.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate', 'wsiteapi'], function () {
        // let {form, layer, layedit, laydate} = [layui.form, layui.layer, layui.layedit, layui.laydate];
        var form = layui.form,
            layer = layui.layer,
            layedit = layui.layedit,
            wsiteapi = layui.wsiteapi,
            laydate = layui.laydate;

        wsiteapi.init();

        laydate.render({
            elem: '#pub_time',
        });

        var introEditorIndex = layedit.build('lay_intro_editor');

        // 自定表单校验脚本
        form.verify({
            intro: function (value) {
                layedit.sync(introEditorIndex);

            }
        });

        // 监听表单提交事件
        form.on('submit(save)', function (data) {
            var param = data.field,
                successCallable = function (data, status) {
                    if (data.code === 200) {
                        layer.msg(data.msg, function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });

                    }
                },
                failedCallable = function (err, textStatus) {
                    layer.msg(textStatus);
                };
            wsiteapi.modifyFilm(param, successCallable, failedCallable);
            // layer.alert(JSON.stringify(data.field), {
            //     title: '表单信息',
            // });
            return false;
        });

    });
</script>

</body>
</html>
